package org.a007;
/**
 * 这个demo说明了 synchronized 锁定对象后 还是可以执行 同一对象的其它非同步方法m2
 * 因为m2是非同步方法所以不受是否拿到锁的影响
 * @author yang 
 *
 */
public class T {
	public synchronized void m1(){
		System.out.println(Thread.currentThread().getName()+" m1 start");
		try {
			Thread.sleep(1000);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		System.out.println(Thread.currentThread().getName()+" m1 end");
	}
	public void m2(){
		try {
			Thread.sleep(1000);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		System.out.println(Thread.currentThread().getName()+" m2");
	}
	public static void main(String[] args) {
		T t = new T();
		new Thread(t::m1,"t1").start();
		new Thread(t::m2,"t2").start();
	}
}
